<?php
include_once("functions/db_manipulate.php");

if (!init()) {
    redirect("login.php");
}
$id = 0;
$guest = false;

if (isset($_GET['uid']) && $_GET['uid'] != $_SESSION['id']) {
    $id = $_GET['uid'];
    $guest = true;
} else {
    $id = $_SESSION['id'];
    $guest = false;
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Профиль</title>
    <link rel="stylesheet" href="css/navigation.css">
    <link rel="stylesheet" type="text/css" href="css/news.css">
    <link rel="stylesheet" type="text/css" href="css/square.css">
    <link rel="stylesheet" type="text/css" href="css/menu.css">
    <link rel="stylesheet" type="text/css" href="css/common.css">
    <link rel="stylesheet" type="text/css" href="css/profile.css">
    <script src="resources/jquery.js"></script>

    <meta charset="UTF-8">
    <script language="JavaScript">
        function customFormSubmit() {
            $('#maximized_navigation').show();
            $('#galimgform').submit();
        }
    </script>
</head>
<body class="body">
<?php
include_once("menu.php");
?>

<div id="square">
    <div id="menu">

        <div class="menubutton" onclick="location.href='profile.php?page=img<?php if ($_GET['uid'] != '') {
            echo "&uid=" . $_GET['uid'];
        } ?>'">
            Изображение
        </div>
        <div class="menubutton" onclick="location.href='profile.php?page=gallery<?php if ($_GET['uid'] != '') {
            echo "&uid=" . $_GET['uid'];
        } ?>'">
            Галерея
        </div>
        <div class="menubutton" onclick="location.href='profile.php?page=stat<?php if ($_GET['uid'] != '') {
            echo "&uid=" . $_GET['uid'];
        } ?>'">
            Статистика
        </div>
        <?php
        if (!$guest) {
            ?>
            <div class="menubutton"
                 onclick="location.href='profile.php?page=sections'">
                Подписки
            </div>
            <div class="menubutton" onclick="location.href='profile.php?page=groups'">
                Группы
            </div>
            <div class="menubutton" onclick="location.href='profile.php?page=info'">
                Информация
            </div>
            <div class="menubutton" onclick="location.href='profile.php?page=settings'">
                Настройки
            </div>
        <?php
        }
        ?>

    </div>

    <?php

    switch ($_GET['page']) {
        case 'img':
            include_once("profile/profile_img.php");
            break;
        case 'sections':
            if (!$guest) {
                include_once("profile/profile_sections.php");
            }
            break;
        case 'stat':
            include_once("profile/profile_stat.php");
            break;
        case 'groups':
            if (!$guest) {
                include_once("profile/profile_groups.php");
            }
            break;
        case 'info':
            if (!$guest) {
                include_once("profile/profile_info.php");
            }
            break;
        case 'settings':
            if (!$guest) {
                include_once("profile/profile_settings.php");
            }
            break;
        case 'gallery':
            include_once("profile/profile_gallery.php");
            break;
        default:
            include_once("profile/profile_img.php");
            break;
    }

    ?>

</div>

<?php
include_once("navigation.html");
?>
</body>
</html>